@extends('layouts.admin')
@push('morecss')
    <!-- Bootstrap Treeview -->
    <link rel="stylesheet" type="text/css" href="{{ asset('/vendor/bootstrap-treeview/dist/bootstrap-treeview.min.css') }}"/>
@endpush

@push('morescript')
    <!-- Bootstrap Treeview -->
    <script src="{{ asset('/vendor/bootstrap-treeview/dist/bootstrap-treeview.min.js') }}"></script>
    <script type="application/javascript">
        let page_params = {
            @can('admin.wxmenu.index')
            url_list: '{{ route('admin.wxmenu.index') }}',
            @endcan
            @can('admin.wxmenu.create')
            url_add: '{{ route('admin.wxmenu.create') }}',
            @endcan
            @can('admin.wxmenu.update')
            url_edit: '{{ route('admin.wxmenu.update') }}',
            @endcan
            @can('admin.wxmenu.destroy')
            url_del: '{{ route('admin.wxmenu.destroy') }}',
            @endcan
            @can('admin.wxmenu.publish')
            url_publish: '{{ route('admin.wxmenu.publish') }}',
            @endcan
            @can('admin.wxmenu.sync')
            url_sync: '{{ route('admin.wxmenu.sync') }}',
            @endcan
            data_area: @json($areaList),
        };
    </script>
    <!-- require page js -->
    <script src="{{ mix('js/admin/wxmenu_index.js') }}"></script>
@endpush
@section('content')
    <!-- 主体内容 -->
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="ibox-content m-b-sm border-bottom">
            @can('admin.wxmenu.create')
                <button class="btn btn-primary" type="button" id="btn-add"><i class="fa fa-plus"></i>
                    添加菜单
                </button>
            @endcan
            @can('admin.wxmenu.publish')
                <button class="btn btn-primary" type="button" id="btn-publish"><i class="fa fa-cloud-upload"></i>
                    发布
                </button>
            @endcan
            @can('admin.wxmenu.sync')
                <button class="btn btn-primary" type="button" id="btn-sync"><i class="fa fa-cloud-download"></i>
                    同步微信端
                </button>
            @endcan
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5>菜单列表</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="treeview" id="tree"></div>
                    </div>

                </div>
            </div>
        </div>
    </div>

    <!-- 节点操作询问层 -->
    <div class="ibox-content" id="box_ask" style="display: none">
        <div class="form-horizontal m-t">
            <div class="form-group" style="text-align: center">
                @can('admin.wxmenu.create')
                    <button class="btn btn-success" type="button" id="btn-add-child">
                        <i class="fa fa-plus"></i>
                        添加子菜单
                    </button>
                @endcan
                @can('admin.wxmenu.update')
                    <button class="btn btn-primary" type="button" id="btn-edit">
                        <i class="fa fa-edit"></i>
                        编辑菜单
                    </button>
                @endcan
                @can('admin.wxmenu.destroy')
                    <button class="btn btn-danger" type="button" id="btn-del">
                        <i class="fa fa-trash-o"></i>
                        删除菜单
                    </button>
                @endcan
            </div>
        </div>
    </div>
    <!-- 节点操作询问层 -->
    <!-- 菜单编辑model -->
    <div class="ibox-content" id="box-form" style="display: none">
        <form class="form-horizontal m-t" method="post" action="">
            <input type="hidden" name="menu_id" id="menu_id"/>
            <input type="hidden" name="parent_id" id="parent_id" value=""/>
            <div class="form-group">
                <label class="col-sm-3 control-label">菜单名称：</label>
                <div class="input-group col-sm-7">
                    <input id="name" type="text" class="form-control" name="name" required="" aria-required="true">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">菜单类型：</label>
                <div class="input-group col-sm-5">
                    <select id="type" name="type" class="form-control">
                        <option value="">请选择</option>
                        @foreach($typeList as $k => $v)
                        <option value="{{ $k }}">{{ $v }}</option>
                        @endforeach
                    </select>
                    <span class="help-block m-b-none">如该菜单为一级菜单时选择点击类型</span>
                </div>
            </div>
            <div class="form-group hidebox keybox">
                <label class="col-sm-3 control-label">菜单KEY值：</label>
                <div class="input-group col-sm-7">
                    <input id="key" type="text" class="form-control" name="key" aria-required="true">
                </div>
            </div>
            <div class="form-group hidebox urlbox">
                <label class="col-sm-3 control-label">网页链接：</label>
                <div class="input-group col-sm-7">
                    <input id="url" type="text" class="form-control" name="url" aria-required="true">
                    <span class="help-block m-b-none">用户点击菜单打开的链接，当类型为小程序而客户端不支持小程序时将打开本url</span>
                </div>
            </div>
            <div class="form-group hidebox mediaidbox">
                <label class="col-sm-3 control-label">永久素材mediaId：</label>
                <div class="input-group col-sm-7">
                    <input id="media_id" type="text" class="form-control" name="media_id" aria-required="true">
                </div>
            </div>
            <div class="form-group hidebox appidbox">
                <label class="col-sm-3 control-label">小程序appid：</label>
                <div class="input-group col-sm-7">
                    <input id="appid" type="text" class="form-control" name="appid" aria-required="true">
                </div>
            </div>
            <div class="form-group hidebox pagepathbox">
                <label class="col-sm-3 control-label">小程序页面路径：</label>
                <div class="input-group col-sm-7">
                    <input id="pagepath" type="text" class="form-control" name="pagepath" aria-required="true">
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <label class="col-sm-3 control-label">是否个性化菜单：</label>
                <div class="input-group col-sm-4">
                    <label class="radio-inline">
                        <input type="radio" checked="" value="0" id="is_conditional_2" name="is_conditional">否</label>
                    <label class="radio-inline">
                        <input type="radio" value="1" id="is_conditional_1" name="is_conditional">是</label>
                    <span class="help-block m-b-none">用于定义显示该菜单的前置条件</span>
                </div>
            </div>
            <div class="form-group rulebox">
                <label class="col-sm-3 control-label">用户标签：</label>
                <div class="input-group col-sm-4">
                    <select id="tag_id" name="tag_id" class="form-control">
                        <option value="">请选择</option>
                        {!! $tagOptionHtml !!}
                    </select>
                </div>
            </div>
            <div class="form-group rulebox">
                <label class="col-sm-3 control-label">性别：</label>
                <div class="input-group col-sm-2">
                    <select id="sex" name="sex" class="form-control">
                        <option value="">请选择</option>
                        @foreach ($sexList as $k => $v)
                        <option value="{{ $k }}">{{ $v }}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="form-group rulebox">
                <label class="col-sm-3 control-label">客户端版本：</label>
                <div class="input-group col-sm-2">
                    <select id="client_platform_type" name="client_platform_type" class="form-control">
                        <option value="">请选择</option>
                        @foreach ($clientPlatformList as $k => $v)
                        {volist name="clientPlatformList" id="v"}
                        <option value="{{ $k }}">{{ $v }}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="form-group rulebox">
                <label class="col-sm-3 control-label">地区：</label>
                <div class="input-group col-sm-9">
                    <div class="col-sm-4">
                        <select id="country" name="country" class="form-control">
                        </select>
                    </div>
                    <div class="col-sm-4">
                        <select id="province" name="province" class="form-control">
                        </select>
                    </div>
                    <div class="col-sm-4">
                        <select id="city" name="city" class="form-control">
                        </select>
                    </div>
                </div>
            </div>
            <div class="form-group rulebox">
                <label class="col-sm-3 control-label">语言：</label>
                <div class="input-group col-sm-2">
                    <select id="language" name="language" class="form-control">
                        <option value="">请选择</option>
                        @foreach ($langList as $k => $v)
                        <option value="{{ $k }}"> {{ $v }}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <label class="col-sm-3 control-label">排序数字：</label>
                <div class="input-group col-sm-2">
                    <input id="order_num" type="number" min="0" class="form-control" name="order_num" required="" aria-required="true" value="0">
                    <span class="help-block m-b-none">数字越小越靠前</span>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-4">
                    <button class="btn btn-primary btn-sub" type="button">提交</button>
                </div>
            </div>
        </form>
    </div>
@endsection